package com.dy.图.邻接矩阵;

import com.dy.图.GraphKind;
import com.dy.图.IGraph;

public class MGraph implements IGraph {
    public final static int INFINITY = Integer.MAX_VALUE;
    private GraphKind kind;
    private int vexNum, arcNum;
    private Object[] vexs;
    private int[][] arcs;
    public MGraph(){
        this(null,0,0,null,null);
    }

    public MGraph(GraphKind kind, int vexNum, int arcNum, Object[] vexs, int[][] arcs) {
        this.kind = kind;
        this.vexNum = vexNum;
        this.arcNum = arcNum;
        this.vexs = vexs;
        this.arcs = arcs;
    }

    @Override
    public void createGraph() {
        switch (kind){
            case DG: createDG();
                return;
            case UDG: createUDG();
                return;
            case DN: createDN();
                return;
            case UDN: createUDN();
                return;
        }
    }
    public void createDG(){

    }

    public void createUDG(){

    }

    public void createDN(){

    }

    public void createUDN(){

    }

    @Override
    public int getVexNum() {
        return this.vexNum;
    }

    @Override
    public int getArcNum() {
        return this.arcNum;
    }

    @Override
    public Object getVex(int v) {
        return vexs[v];
    }

    @Override
    public int locateVex(Object vex) {
        for(int i=0;i<vexNum;i++){
            if(vexs[i].equals(vex)){
                return i;
            }
        }
        return -1;
    }

    @Override
    public int firstAdjVex(int v) {
        for(int j=0;j<vexNum;j++){
            if(arcs[v][j]!=0 &&arcs[v][j]!=INFINITY){
                return j;
            }
        }
        return -1;
    }

    @Override
    public int nextAdjVex(int v, int w) {
        return 0;
    }

    public GraphKind getKind() {
        return kind;
    }

    public Object[] getVexs() {
        return vexs;
    }

    public int[][] getArcs() {
        return arcs;
    }
}
